﻿function ClientUpdateWebPartMan()
{
    document.getElementById("divProcessing").innerHTML=Portal.SystemWebParts.WebPartMan.WebPartMan.GetUpdateProcessingText().value;
    setTimeout("RealClientUpdateWebPartMan()",100);
}

function RealClientUpdateWebPartMan()
{
    retValue=Portal.SystemWebParts.WebPartMan.WebPartMan.ServerSideAutoUpdate().value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        document.getElementById("divProcessing").innerHTML="";
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML="";
    alert(retValue);
    RunFilter();    
}

function RunFilter()
{
    document.getElementById("divProcessing").innerHTML=Portal.SystemWebParts.WebPartMan.WebPartMan.GetProcessingText().value;
    setTimeout("RealRunFilter()",10);
}

function RealRunFilter()
{
    PageIndex=0;
    if(document.getElementById("divSelectPage")!=null)
    {
        PageIndex=document.getElementById("divSelectPage").selectedIndex;
    }
    Keyword = document.getElementById("txtKeyword").value;
    ShowAll = document.getElementById("chkShowAll").checked.toString();
    value = Portal.SystemWebParts.WebPartMan.WebPartMan.GetWebPartMan(ShowAll,Keyword, PageIndex.toString()).value;
    if(value.indexOf("ERROR")!=-1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(value);
        return;
    }
    document.getElementById("divProcessing").innerHTML="";
    document.getElementById("divWebPartManContent").innerHTML=value;
}

function ChangeStatus(WebPartId)
{
    if(confirm(Portal.SystemWebParts.WebPartMan.WebPartMan.GetConfirmChangeMsg().value)==false)return;
    
    value=Portal.SystemWebParts.WebPartMan.WebPartMan.ServerSideChangeStatus(WebPartId).value;
    if(value.indexOf("ERROR")!=-1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(value);
        return;
    }
    alert(value);
    RealRunFilter();
}

function Delete(WebPartId)
{
    if(confirm(Portal.SystemWebParts.WebPartMan.WebPartMan.GetConfirmMsg().value)==false)return;
    value=Portal.SystemWebParts.WebPartMan.WebPartMan.ServerSideDelete(WebPartId).value;
    if(value.indexOf("ERROR")!=-1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(value);
        return;
    }
    alert(value);
    RealRunFilter();   
}

function SetPermission(WebPartId)
{
    Url=Portal.SystemWebParts.WebPartMan.WebPartMan.GetPermissionUrl(WebPartId).value;
    if(Url.indexOf("ERROR")!=-1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(Url);
        return;
    }
    //window.showModalDialog(Url, "", "dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;");
    window.open(Url, '_blank');
}

function ClientInstallWebPart() {
    document.getElementById("divProcessing").innerHTML = Portal.SystemWebParts.WebPartMan.WebPartMan.GetProcessingText().value;
    setTimeout("RealClientInstallWebPart()", 10);
}


function RealClientInstallWebPart() {
    Keyword = document.getElementById("txtKeyword").value;
    value = Portal.SystemWebParts.WebPartMan.WebPartMan.ServerSideInstallWebPart(Keyword).value;
    if (value.indexOf("ERROR") != -1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(value);
        return;
    }
    document.getElementById("divProcessing").innerHTML = "";
    alert(value);
}


function ClientInstallWebPart1() {
    document.getElementById("divProcessing").innerHTML = Portal.SystemWebParts.InstallWebPartMan.InstallWebPartMan.GetProcessingText().value;
    setTimeout("RealClientInstallWebPart1()", 10);
}


function RealClientInstallWebPart1() {
    Keyword = document.getElementById("txtKeyword").value;
    value = Portal.SystemWebParts.InstallWebPartMan.InstallWebPartMan.ServerSideInstallWebPart(Keyword).value;
    if (value.indexOf("ERROR") != -1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(value);
        return;
    }
    document.getElementById("divProcessing").innerHTML = "";
    alert(value);
}




function ClientUpdateIcon() {
    document.getElementById("divProcessing").innerHTML = Portal.SystemWebParts.WebPartMan.WebPartMan.GetProcessingText().value;
    setTimeout("RealClientUpdateIcon()", 10);
}

function RealClientUpdateIcon() {
    value = Portal.SystemWebParts.WebPartMan.WebPartMan.ServerSideUpdateWebPartIcon().value;
    if (value.indexOf("ERROR") != -1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(value);
        return;
    }
    document.getElementById("divProcessing").innerHTML = "";
    alert(value);
}